﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using yiCommerce.Core;
using yiCommerce.Core.Domain.Customers;

namespace yiCommerce.Controllers
{
    public class BaseController : Controller
    {
        

        protected int GetShopId()
        {
            var workContext = EngineContext.Current.Resolve<IWorkContext>();
            if (workContext != null)
            {
                if (workContext.CurrentCustomer.IsAdmin())
                {
                    return 0;
                }
                else
                {
                    var shopId = workContext.CurrentCustomer.ShopId != null
                                     ? workContext.CurrentCustomer.ShopId.Value
                                     : 0;
                    return shopId;
                }

            }
            return 0;
        }

        public ActionResult AccessDeniedView()
        {
            //return new HttpUnauthorizedResult();
            return View("AccessDenied");
        }
    }
}
